<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title></title>
	</head>

	<body>
		<input type="text" id="input" /> <button id="test">消息发送</button>
		<script type="text/javascript" src="js/pageEvent2.js"></script>
		<!--可以不依赖jq，此处只是为了方便操作dom-->
		<script type="text/javascript" src="js/jquery-3.4.1.min.js"></script>
		<script type="text/javascript">
			pageEvent.storagesource = "storage";
			$(function() {
				var $input = $("#input");
				$("#test").on("click", function() {
					var v = $input.val();
					if(v != "") {
						pageEvent.send("myEvent", {
							msg: v,
							time: Date.now()
						});
						$input.val("");
					}
				});
				$input.on("keyup", function(e) {
					if (e.keyCode==13) {
						$("#test").click();
					}
				});
			});
		</script>
	</body>

</html>